unit SettingsForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TfmSettings = class(TForm)
    Label1: TLabel;
    txtDBLocation: TEdit;
    btnBrowse: TButton;
    btnOK: TButton;
    OpenDialog1: TOpenDialog;
    btnCancel: TButton;
    Label2: TLabel;
    Label3: TLabel;
    txtHostname: TEdit;
    txtPort: TEdit;
    CheckBox1: TCheckBox;
    Label4: TLabel;
    rbPortriat: TRadioButton;
    rbLandscape: TRadioButton;
    Label5: TLabel;
    txtExportPath: TEdit;
    btnExportPath: TButton;
    FileOpenDialog1: TFileOpenDialog;
    procedure btnBrowseClick(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure btnExportPathClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmSettings: TfmSettings;

implementation

{$R *.dfm}

procedure TfmSettings.btnBrowseClick(Sender: TObject);
begin
  FileOpenDialog1.DefaultFolder := ExtractFilePath(txtDBLocation.Text);
  FileOpenDialog1.Options := FileOpenDialog1.Options - [fdoPickFolders];
  if FileOpenDialog1.Execute(Self.WindowHandle) then
    txtDBLocation.Text := FileOpenDialog1.FileName;
end;

procedure TfmSettings.btnOKClick(Sender: TObject);
begin
  Close;
end;

procedure TfmSettings.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then begin
    txtHostname.Enabled := True;
    txtPort.Enabled := True;
  end else begin
    txtHostname.Enabled := False;
    txtHostname.Text := 'localhost';
    txtPort.Enabled := False;
    txtPort.Text := '3050';
  end;
end;

procedure TfmSettings.btnCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TfmSettings.btnExportPathClick(Sender: TObject);
begin
  FileOpenDialog1.DefaultFolder := ExtractFilePath(txtExportPath.Text);
  FileOpenDialog1.Options := FileOpenDialog1.Options + [fdoPickFolders];
  if FileOpenDialog1.Execute(Self.WindowHandle) then
    txtExportPath.Text := FileOpenDialog1.FileName;
end;

end.
